<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a>商品列表</a></li>
        <li><a href="{:url('AdminItem/add')}">添加商品</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="post" action="{:url('AdminItem/index')}">
        分类:
        <select class="form-control" name="category" style="width: 140px;" id="input-search-category">
            <option value='0'>全部</option>
            {$categories_tree|default=''}
        </select> &nbsp;&nbsp;
        关键字:
        <input type="text" class="form-control" name="keyword" style="width: 200px;"
               value="{:input('param.keyword','')}" placeholder="请输入关键字...">
        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger" href="{:url('AdminItem/index')}">清空</a>
    </form>
    <form method="post" class="js-ajax-form" action="{:url('AdminItem/listOrder')}">
        <php>
            $status=['0'=>'下架','1'=>'上架'];
        </php>
        <div class="table-actions">
            <button class="btn btn-primary btn-sm js-ajax-submit" type="submit">{:lang('SORT')}</button>
            <button class="btn btn-primary btn-sm js-ajax-submit" type="submit"
                    data-action="{:url('AdminItem/status',array('sell'=>1))}" data-subcheck="true"
                    data-msg="你确定上架这些商品吗？">
                上架
            </button>
            <button class="btn btn-danger btn-sm js-ajax-submit" type="submit"
                    data-action="{:url('AdminItem/status',array('sell'=>0))}" data-subcheck="true"
                    data-msg="你确定下架这些商品吗？">
                下架
            </button>
        </div>
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th width="16">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <th>排序</th>
                <th>商品名称</th>
                <th>分类</th>
                <th>价格(元)</th>
                <th>上下架</th>
                <th>操作</th>
            </tr>
            </thead>

            <tbody>
            <foreach name="items" item="vo">
                <tr>
                    <td>
                        <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                               value="{$vo.id}">
                    </td>
                    <td>
                        <input name="list_orders[{$vo.id}]" class="input input-order" type='text' size='3'
                               value='{$vo.list_order}'>
                    </td>
                    <td>
                        <a href="{:cmf_url('mall/Item/index',['id'=>$vo.id])}" target="_blank">
                            <img src="{:cmf_get_image_url($vo.thumbnail)}" style="width: 60px;height: 60px;"/>
                            {$vo.title}
                        </a>
                    </td>
                    <td>
                        <a href="{:cmf_url('mall/List/index',['id'=>$vo.category_id])}" target="_blank">{$vo.category.name}</a>
<!--                        （{$vo.model.name}）-->
                    </td>
                    <td>￥{$vo.price}</td>
                    <td>{$status[$vo.status]}</td>
                    <td>
                        <a class="btn btn-primary btn-sm" href="{:url('mall/AdminItem/edit',['id'=>$vo.id])}">编辑</a>
                    </td>
                </tr>
            </foreach>
            </tbody>
            <tfoot>
            <tr>
                <th width="16">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <th>排序</th>
                <th>商品名称</th>
                <th>分类</th>
                <th>价格(元)</th>
                <th>上下架</th>
                <th>操作</th>
            </tr>
            </tfoot>
        </table>
        <div class="table-actions">
            <button class="btn btn-primary btn-sm js-ajax-submit" type="submit">{:lang('SORT')}</button>
            <button class="btn btn-primary btn-sm js-ajax-submit" type="submit"
                    data-action="{:url('AdminItem/status',array('sell'=>1))}" data-subcheck="true"
                    data-msg="你确定上架这些商品吗？">
                上架
            </button>
            <button class="btn btn-danger btn-sm js-ajax-submit" type="submit"
                    data-action="{:url('AdminItem/status',array('sell'=>0))}" data-subcheck="true"
                    data-msg="你确定下架这些商品吗？">
                下架
            </button>
        </div>
    </form>
    <ul class="pagination">{$page|default=''}</ul>

</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
    $('#input-search-category').val("{:input('param.category',0,'intval')}");
</script>
</body>
</html>